package com.mf.morefun.widget;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;

import com.mf.morefun.R;
import com.mf.morefun.ui.personnelmanagement.PersonnelManagementActivity;
import com.zhcx.zhcxlibrary.utils.DeviceUtils;
import com.zhcx.zhcxlibrary.utils.StringUtils;

public class LoginErrorDialog extends Dialog{
    private String message;
    private Context mContext;
    public LoginErrorDialog(@NonNull Context context) {
        super(context);
    }

    public LoginErrorDialog(@NonNull Context context, int themeResId, String message) {
        super(context, themeResId);
        this.message = message;
        this.mContext = context;
    }

    protected LoginErrorDialog(@NonNull Context context, boolean cancelable, @Nullable OnCancelListener cancelListener) {
        super(context, cancelable, cancelListener);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        View contentView = LayoutInflater.from(getContext()).inflate(R.layout.layout_loginerror, null);
        setContentView(contentView);
        setCancelable(false);
        TextView tv_sure = contentView.findViewById(R.id.tv_sure);
        tv_sure.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
        if (!StringUtils.isEmpty(message)){
            TextView tv_message = contentView.findViewById(R.id.tv_message);
            tv_message.setText(message);
        }
        Window dialogWindow = getWindow();
        WindowManager.LayoutParams lp = dialogWindow.getAttributes();
        lp.width = (int) (DeviceUtils.deviceWidth(mContext) * 0.4);
        lp.height = (int) (DeviceUtils.deviceWidth(mContext) * 0.3);
        dialogWindow.setAttributes(lp);
    }
}
